/*
 *   AS IS License
 * ==Naive Coders==
 */
package com.naivecoders.refex;

import com.naivecoders.refex.functions.AbstractFunction;
import com.naivecoders.refex.functions.FCode;
import com.naivecoders.refex.functions.InvocationException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;

/**
 *
 * @author gbu.000
 */
public class Run {
    
    public static void main(String[] args) throws IOException,
            IllegalSyntaxException,
            InvocationException {
        final Namespace globalNs = new Namespace();
        final FunctionFactory ff = new FunctionFactory(globalNs);
        final Compiler c = new Compiler(globalNs, ff);
        final Reader r = new InputStreamReader(
                Run.class.getResourceAsStream("code/test.rfx"));
        c.parce(r);
        r.close();
        System.out.println(globalNs.get(new FName(FCode.E, FCode.I)));
        
        System.out.println(globalNs.getEntry());
        
        try {
            final AbstractFunction result = globalNs.getEntry().evaluate(ff.emptyList());
        System.out.println(result);
        } catch (InvocationException ex) {
            ex.dump(System.err);
        }
    }
}
